package com.ideaaedi.commonspring.lite.params;

/**
 * 参数记录器
 *
 * @author <font size = "20" color = "#3CAA3C"><a href="https://gitee.com/JustryDeng">JustryDeng</a></font> <img
 * src="https://gitee.com/JustryDeng/shared-files/raw/master/JustryDeng/avatar.jpg" />
 * @since 1.0.0
 */
public @interface ParameterRecorder {
    
    /** 默认格式 */
    String POINTCUT_FORMAT =
            "("
                + "@within(com.ideaaedi.commonspring.lite.params.RecordParameters)"
                + " || "
                + "@annotation(com.ideaaedi.commonspring.lite.params.RecordParameters)"
                + "%s"
            + ")"
            + " && "
            + "!@annotation(com.ideaaedi.commonspring.lite.params.IgnoreRecordParameters)"
            + "%s";
    
    /** 默认切点 */
    String DEFAULT_POINTCUT = String.format(POINTCUT_FORMAT, "", "");
    
    /**
     * 需要包含的methodReference前缀
     * <pre>
     *
     *  为空则表示全部包含
     *
     *  methodReference形如：com.ideaaedi.commonspring.aop.ParameterRecorderAdvice#init
     * </pre>
     */
    String[] includePrefixes() default {};
    
    /**
     * 需要排除的methodReference前缀
     * <pre>
     *
     *  为空则表示都不需要排除
     *
     *  methodReference形如：com.ideaaedi.commonspring.aop.ParameterRecorderAdvice#init
     * </pre>
     */
    String[] excludePrefixes() default {};
    
    /**
     * 将参数转换为字符串的方式
     */
    ParameterHandleModeEnum parameterHandleMode() default ParameterHandleModeEnum.USE_JSON;
    
    /**
     * 记录日志时，是否美化
     */
    boolean pretty() default true;
    
    /**
     * 当参数类型是这些时，不打印该参数
     */
    Class[] ignoreParamTypes() default {};
    
    /**
     * 切点and匹配
     * <pre>
     * {@code
     * 默认切点是：
     * @Pointcut(
     *        "("
     *             + "@within(com.ideaaedi.commonspring.lite.params.RecordParameters)"
     *             + " || "
     *             + "@annotation(com.ideaaedi.commonspring.lite.params.RecordParameters)"
     *         + ")"
     *         + " && "
     *         + "!@annotation(com.ideaaedi.commonspring.lite.params.IgnoreRecordParameters)"
     * )
     *
     * 在最后面增加 && 拼接你配置的切点。假设你配置的切点是execution(* *..*RequestHandler.invoke(..))，那么拼接后形如：
     * @Pointcut(
     *        "("
     *             + "@within(com.ideaaedi.commonspring.lite.params.RecordParameters)"
     *             + " || "
     *             + "@annotation(com.ideaaedi.commonspring.lite.params.RecordParameters)"
     *         + ")"
     *         + " && "
     *         + "!@annotation(com.ideaaedi.commonspring.lite.params.IgnoreRecordParameters)"
     *         + " && "
     *         + "execution(* *..*RequestHandler.invoke(..))"
     * )
     * }
     * </pre>
     */
    String[] pointcutAnd() default {};

    /**
     * 切点or匹配
     * <pre>
     * {@code
     * 默认切点是：
     * @Pointcut(
     *        "("
     *             + "@within(com.ideaaedi.commonspring.lite.params.RecordParameters)"
     *             + " || "
     *             + "@annotation(com.ideaaedi.commonspring.lite.params.RecordParameters)"
     *         + ")"
     *         + " && "
     *         + "!@annotation(com.ideaaedi.commonspring.lite.params.IgnoreRecordParameters)"
     * )
     *
     * 在括号中增加 || 拼接你配置的切点。假设你配置的切点是execution(* *..*RequestHandler.invoke(..))，那么拼接后形如：
     * @Pointcut(
     *        "("
     *             + "@within(com.ideaaedi.commonspring.lite.params.RecordParameters)"
     *             + " || "
     *             + "@annotation(com.ideaaedi.commonspring.lite.params.RecordParameters)"
     *             + " || "
     *             + "execution(* *..*RequestHandler.invoke(..))"
     *         + ")"
     *         + " && "
     *         + "!@annotation(com.ideaaedi.commonspring.lite.params.IgnoreRecordParameters)"
     * )
     * }
     * </pre>
     */
    String[] pointcutOr() default {"execution(* *..*Controller.*(..))"};
}
